<template>
	<view class="content">
		<scroll-view class="scroll-view-y" scroll-top="40" :show-scrollbar="true" scroll-y="true" upper-threshold="40"
			@scrolltoupper="touchTop" lower-threshold="40" @scrolltolower="touchLower" @scroll="scroll"
			scroll-with-animation="true">
			<view class="box" v-for="index in 10">
			</view>
		</scroll-view>

		<scroll-view class="scroll-view-x" scroll-x="true" upper-threshold="40" @scrolltoupper="touchTop"
			lower-threshold="40" @scrolltolower="touchLower">
			<view  class="box" v-for="index in 10">
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
			}
		},
		onLoad() {
		},
		methods: {
			touchTop(e) {
				console.log("碰到顶了==========" + e);
			},
			touchLower(e) {
				console.log("碰到底了==========" + e);
			},
			scroll(e) {
				console.log("scroll==========" + e);
			},
			getRandomColor() {
				return '#' + (function(color) {
					return (color += '0123456789abcdef' [Math.floor(Math.random() * 16)]) &&
						(color.length == 6) ? color : arguments.callee(color);
				})('');
			}

		}
	}
</script>

<style>
	.content {
		padding-right: 20rpx;

		.scroll-view-y {
			height: 600rpx;
			border: 1rpx red solid;
			padding: 10rpx;

			.box {
				width: 300rpx;
				height: 300rpx;
				border: 1rpx saddlebrown solid;
				background-color: aqua;
				margin: 10rpx;
			}
		}

		.scroll-view-x {
			height: 600rpx;
			border: 1rpx red solid;
			padding: 10rpx;
			width: 100%;
			white-space: nowrap;

			.box {
				width: 300rpx;
				height: 300rpx;
				border: 1rpx saddlebrown solid;
				background-color: aqua;
				margin: 10rpx;
				display: inline-block;
			}

		}
	}
</style>